What makes _SERVER stop working
What makes _SERVER stop working
am 03.08.2009 19:26:35 von tmiller
All of a sudden this stopped working and keeps defaulting to A again
if ($_SERVER['SCRIPT_FILENAME'] =3D "browse.php" ) {
$default =3D "A";
=20
}
=20
else {
=20
$default =3D "";=20
=20
}
=20
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: What makes _SERVER stop working
am 03.08.2009 19:40:18 von jenai tomaka
--_70619812-91ba-43c4-bbbc-4f77bcf37848_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Maybe the $_SERVER variable has been disable in the server=2C if is it=2C y=
ou will just need enable the $_SERVER again
Yuri Yarlei.
Programmer PHP=2C CSS=2C Java=2C PostregreSQL=3B
Today PHP=2C tomorrow Java=2C after the world.
Kyou wa PHP=2C ashita wa Java=2C sono ato sekai desu.
=20
> From: tmiller@springfi.gannett.com
> To: php-general@lists.php.net
> Date: Mon=2C 3 Aug 2009 10:26:35 -0700
> Subject: [PHP] What makes _SERVER stop working
>=20
> All of a sudden this stopped working and keeps defaulting to A again
>=20
> if ($_SERVER['SCRIPT_FILENAME'] =3D "browse.php" ) {
>=20
> $default =3D "A"=3B
>=20
> }
>=20
>=20
> else {
>=20
> $default =3D "";
>=20
> }
>=20
>=20
>=20
> --=20
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe=2C visit: http://www.php.net/unsub.php
>=20
____________________________________________________________ _____
Descubra todas as novidades do novo Internet Explorer 8
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=3DMS N%3BHotmail&utm=
_medium=3DTagline&utm_campaign=3DIE8=
--_70619812-91ba-43c4-bbbc-4f77bcf37848_--
Re: What makes _SERVER stop working need default view to shownothing
am 03.08.2009 20:19:12 von tmiller
On 8/3/09 12:26 PM, "Miller, Terion" wrote:
All of a sudden this stopped working and keeps defaulting to A again
if ($_SERVER['SCRIPT_FILENAME'] =3D "browse.php" ) {
$default =3D "A";
}
else {
$default =3D "";
}
I was using the above successfully until the boss rewrote the script now it=
defaults to the A's again....and that script_filename doesn't work...
=
//if the page is browse default to A's if on other pages just show paginati=
on links and not default listings =
=
//Create =
array with letters AND number sign $letters =3D rang=
e('A','Z'); array_push($letters, 'nums'); =
$menu =3D ''; $=
selectedLetter =3D isset($_GET['letter']) ? $_GET['letter'] : NULL; =
=
foreach($letters as $letter) =
{ if($letter == $selectedLetter=
&& $selectedLetter !=3D 'nums') { =
$menu .=3D sprintf('%s ', $letter); =
} else if($letter == $selectedLett=
er && $selectedLetter == 'nums') { =
$menu .=3D sprintf('%s ', '#'); =
} else { =
if($letter == 'nums') =
{ $menu .=3D sprintf('
=3D"browseMatt.php?letter=3D%s">%s ', 'nums', '#'); =
} else =
{ $menu .=3D sprintf('
=3D"browseMatt.php?letter=3D%s">%s ', $letter, $letter); =
} } =
} echo "
\"center\">{$menu}
"; =
=
=
//Show =
all restaurants that start with $letter not between "A" and "Z" =
if ($selectedLetter == "nums") { =
for($i =3D 0; $i <=3D 9; $i++) =
{ $sql =3D "SELECT DISTINCT ID, name=
, address FROM restaurants WHERE name LIKE '$i%'"; =
$res=
ult =3D mysql_query($sql) or die(mysql_error()); =
while($row =3D mysql_fetch_assoc($result))=
{ $name =
=3D $row['name']; printf('
ew.php?ID=3D%s">%s
%s
', $row['ID'], $row['name'=
], $row['address']); =
} } =
} =
else { $sql =3D "S=
ELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE '$selecte=
dLetter%'"; $result =
=3D mysql_query($sql) or die(mysql_error()); =
while($row =3D mysql_fetch_assoc($result)) =
{ $name =3D $row['name']=
; printf('%=
s
%s
', $row['ID'], $row['name'], $row['address']);=
} =
} =
=
=
=
=
=
=
=
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What makes _SERVER stop working
am 03.08.2009 20:40:45 von Ollisso
On Mon, 03 Aug 2009 20:26:35 +0300, "Miller, Terion"
wrote:
> All of a sudden this stopped working and keeps defaulting to A again
>
> if ($_SERVER['SCRIPT_FILENAME'] = "browse.php" ) {
>
> $default = "A";
> }
>
> else {
> $default = "";
> }
>
it should be:
if ($_SERVER['SCRIPT_FILENAME'] == "browse.php" ) {
....
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What makes _SERVER stop working
am 03.08.2009 20:43:46 von Ben Dunlap
Miller, Terion wrote:
> if ($_SERVER['SCRIPT_FILENAME'] = "browse.php" ) {
You're using the assignment operator above ('=') instead of the comparison
('=='). If that's not simply a typo that entered the code when you composed
your email, then that's the source of your problem.
You might consider putting the literal side of your comparisons on the left of
the operator. Using the example above you could write:
if ("browse.php" == $_SERVER['SCRIPT_FILENAME']) {
This way if you accidentally use the assignment operator, PHP will give you a
parse error before it even tries to execute the script.
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: What makes _SERVER stop working
am 03.08.2009 20:48:08 von tmiller
On 8/3/09 1:40 PM, "Ollisso" wrote:
On Mon, 03 Aug 2009 20:26:35 +0300, "Miller, Terion"
wrote:
> All of a sudden this stopped working and keeps defaulting to A again
>
> if ($_SERVER['SCRIPT_FILENAME'] =3D "browse.php" ) {
>
> $default =3D "A";
> }
>
> else {
> $default =3D "";
> }
>
it should be:
if ($_SERVER['SCRIPT_FILENAME'] == "browse.php" ) {
....
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thanks but it still doesn't work, it defaults to 'A' and I want it to defau=
lt to show 'A" only on browse.php all other pages should show NO default se=
lections.
'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: What makes _SERVER stop working
am 03.08.2009 21:22:51 von Ollisso
On Mon, 03 Aug 2009 21:48:08 +0300, "Miller, Terion"
wrote:
>
> Thanks but it still doesn't work, it defaults to 'A' and I want it to
> default to show 'A" only on browse.php all other pages should show NO
> default selections.
> '
Create file with this content:
and run it with browser.
and then check - do you have what you need there ?
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: What makes _SERVER stop working
am 03.08.2009 21:58:13 von tmiller
On 8/3/09 2:22 PM, "Ollisso" wrote:
On Mon, 03 Aug 2009 21:48:08 +0300, "Miller, Terion"
wrote:
>
> Thanks but it still doesn't work, it defaults to 'A' and I want it to
> default to show 'A" only on browse.php all other pages should show NO
> default selections.
> '
Create file with this content:
and run it with browser.
and then check - do you have what you need there ?
--
It's there, could it be I have it in the wrong place in the script?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What makes _SERVER stop working
am 04.08.2009 02:44:46 von Shawn McKenzie
Miller, Terion wrote:
> All of a sudden this stopped working and keeps defaulting to A again
>
> if ($_SERVER['SCRIPT_FILENAME'] = "browse.php" ) {
>
> $default = "A";
>
> }
>
>
> else {
>
> $default = "";
>
> }
>
It stopped working or never worked because your if statement is wrong ==
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: What makes _SERVER stop working (RESOLVED)
am 04.08.2009 21:22:20 von tmiller
On 8/3/09 7:44 PM, "Shawn McKenzie" wrote:
Miller, Terion wrote:
> All of a sudden this stopped working and keeps defaulting to A again
>
> if ($_SERVER['SCRIPT_FILENAME'] =3D "browse.php" ) {
>
> $default =3D "A";
>
> }
>
>
> else {
>
> $default =3D "";
>
> }
>
It stopped working or never worked because your if statement is wrong =3D=
=3D
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Right, I need to mark this one resolved I finally got it to work with this:
// Main controller which page to show. if (isset($_GET['letter'])) { brow=
se($_GET['letter']); } elseif (basename($_SERVER['SCRIPT_FILENAME']) ===
"browse.php" ) { browse('A'); } else { index(); }
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php